﻿using Propro.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PagedList;

namespace Propro.Controllers
{
    [Authorize(Roles = "Administration")]
    public class LogController : Controller
    {

        private ProWebContext _db = new ProWebContext();

        public ActionResult Index(int page = 1)
        {
            if (User.IsInRole("Administration"))
            {
                var model = _db.Logs.OrderByDescending(l => l.Date).ToPagedList(page, 10);
                return View(model);
            }
            else
            {
                return RedirectToAction("List", "Projects");
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (_db != null)
            {
                _db.Dispose();
            }

            base.Dispose(disposing);
        }

    }
}
